<?php 
class adminMenu_models_index extends models{

    
    public function getAdminMenu(){
    	$parents=$this->db->select('*')->from('admin_menu')->where(
    							array(	'parent'=>0,
    									'active'=>1)
    							)->order_by('order','ASC')->get()->result();
    	foreach ($parents as $key=>$itemParent){
    	
    		$subItem=$this->db->select('*')->from('admin_menu')->where(
    							array(	'parent'=>$itemParent->id,
    									'active'=>1,
    								)
    							)->order_by('order')->get()->result();
    		if(is_array($subItem))
    			$parents[$key]->subMenu=$subItem;
    	}
    	return $parents;
    }
}